SQL QuickStart Guide by ClydeBank Technology

SQL QuickStart Guide by ClydeBank Technology

Author:ClydeBank Technology
Language: eng
Format: epub
Publisher: ClydeBank Media LLC
Published: 2017-06-13T00:31:52+00:00


fg. 22 : Presenting table data as sets

When we join these sets of records with an INNER JOIN (Figure 23), we essentially include only those records in which there is an overlap as defined by the ON clause.

fg. 23 : Overlapping sets with INNER JOIN

An inner join requires that both sets of records involved in the join include matching records. If we want to include records from either side of the sets that are not overlapping, we need to use an outer join. An outer join doesn’t require a match on both sides, as we can specify which table will always return results regardless of the conditions in the ON clause. There are three types of outer joins: left outer join, right outer join, and full outer join. The syntax is identical to that for inner joins; the only change is the OUTER JOIN keyword.

In a left outer join, all the records from the table named on the left of the OUTER JOIN statement are returned, regardless of whether there is a matching record in the table on the right of the OUTER JOIN statement. For example (Figure 24), the following query:

SELECT Products.ProductName, Categories.

CategoryName

FROM Categories LEFT OUTER JOIN Products

ON Categories.CategoryID=Products.CategoryID



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.